package entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="administraciones")
public class AdministracionEntity implements Serializable{

	@Transient
	private static final long serialVersionUID = 1L;

	@Id @GeneratedValue
	private Integer id;
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="idPlanProduccion")
	private PlanProduccionEntity planProduccion = new PlanProduccionEntity();
	@OneToMany(cascade=CascadeType.ALL)
	@JoinColumn(name="idAdministracion")
	private List<ProveedorEntity> proveedores = new ArrayList<ProveedorEntity>();
	
	
	public AdministracionEntity() {

	}
	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public PlanProduccionEntity getPlanProduccion() {
		return planProduccion;
	}
	public void setPlanProduccion(PlanProduccionEntity planProduccion) {
		this.planProduccion = planProduccion;
	}
	public List<ProveedorEntity> getProveedores() {
		return proveedores;
	}
	public void setProveedores(List<ProveedorEntity> proveedores) {
		this.proveedores = proveedores;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((planProduccion == null) ? 0 : planProduccion.hashCode());
		result = prime * result
				+ ((proveedores == null) ? 0 : proveedores.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AdministracionEntity other = (AdministracionEntity) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (planProduccion == null) {
			if (other.planProduccion != null)
				return false;
		} else if (!planProduccion.equals(other.planProduccion))
			return false;
		if (proveedores == null) {
			if (other.proveedores != null)
				return false;
		} else if (!proveedores.equals(other.proveedores))
			return false;
		return true;
	}
	
}
